package com.itheima.health.controller.backend;

import com.itheima.health.entity.Result;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author: CB
 * @Description:
 * @Date: 2024/11/11 下午11:13
 * @Version: 1.0
 */
@RestController
public class loginController {
    @RequestMapping("/login.do")
    public Result add(@RequestParam String  username,@RequestParam  String  password, ServletResponse response) throws IOException {
        System.out.println(username);
        System.out.println(password);
        if(username.equals("cbadmin") && password.equals("cbadmin")){
            ((HttpServletResponse) response).sendRedirect("http://localhost:80/backend/pages/main.html");
        }
        // 2.响应统一结果Result
        return new Result(true, "登录成功");
    }
}
